﻿using System;

namespace Fibre.Threading.Tests
{
    public class TestAsyncClass
    {
        public IAsyncResult BeginTest(AsyncCallback asyncCallback, object state)
        {
            var asyncResult = new AsyncResult<string>(asyncCallback, state);
            asyncResult.Complete("All good", true);
            return asyncResult;
        }

        public string EndTest(IAsyncResult asyncResult)
        {
            var result = asyncResult as AsyncResult<string>;
            if (result != null)
                return result.Result;

            throw new InvalidOperationException("IAsyncResult should be AsyncResult");
        }
    }
}
